package changedb;


import java.awt.image.BufferedImage;
import java.io.File;
import java.util.ArrayList;
import javax.imageio.ImageIO;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.UIManager;

/**
 * Main Frame GUI
 * 
 * @author Ben Goodwin
 * @version 2.0 16/09/2011
 */
public class MainFrame extends javax.swing.JFrame {

    /** Creates new form MainFrame */
    public MainFrame() {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (Exception e) {
        }
        initComponents();
        createImages();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jSplitPane1 = new javax.swing.JSplitPane();
        jPanel4 = new javax.swing.JPanel();
        filterChooser = new javax.swing.JComboBox();
        searchBox = new javax.swing.JTextField();
        filter = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        ml = new changedb.MembersList();
        details = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        address = new javax.swing.JTextArea();
        pic = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jScrollPane3 = new javax.swing.JScrollPane();
        other = new javax.swing.JTextArea();
        jPanel1 = new javax.swing.JPanel();
        jLabel5 = new javax.swing.JLabel();
        medical = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        nameLabel = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        mum = new javax.swing.JTextField();
        jLabel6 = new javax.swing.JLabel();
        dad = new javax.swing.JTextField();
        name = new javax.swing.JTextField();
        sosNum = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        dob = new javax.swing.JTextField();
        email = new javax.swing.JTextField();
        type = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        school = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        mobile = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        toolbar = new javax.swing.JToolBar();
        openTB = new javax.swing.JButton();
        saveTB = new javax.swing.JButton();
        saveasTB = new javax.swing.JButton();
        encryptTB = new javax.swing.JButton();
        closeTB = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JToolBar.Separator();
        addTB = new javax.swing.JButton();
        editTB = new javax.swing.JButton();
        deleteTB = new javax.swing.JButton();
        jSeparator2 = new javax.swing.JToolBar.Separator();
        mailto = new javax.swing.JButton();
        jSeparator3 = new javax.swing.JToolBar.Separator();
        attendanceTB = new javax.swing.JButton();
        viewAttTB = new javax.swing.JButton();
        status = new javax.swing.JLabel();
        jToolBar1 = new javax.swing.JToolBar();
        helpTB = new javax.swing.JButton();
        aboutTB = new javax.swing.JButton();
        menuBar = new javax.swing.JMenuBar();
        fileMenu = new javax.swing.JMenu();
        open = new javax.swing.JMenuItem();
        jMenu1 = new javax.swing.JMenu();
        save = new javax.swing.JMenuItem();
        saveAs = new javax.swing.JMenuItem();
        encrypt = new javax.swing.JMenuItem();
        close = new javax.swing.JMenuItem();
        exit = new javax.swing.JMenuItem();
        editMenu = new javax.swing.JMenu();
        add = new javax.swing.JMenuItem();
        edit = new javax.swing.JMenuItem();
        delete = new javax.swing.JMenuItem();
        jMenu2 = new javax.swing.JMenu();
        takeAttendance = new javax.swing.JMenuItem();
        viewAttendance = new javax.swing.JMenuItem();
        helpMenu = new javax.swing.JMenu();
        help = new javax.swing.JMenuItem();
        about = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
        setTitle("ChangeDB");
        setFont(new java.awt.Font("Verdana", 0, 12));
        setMinimumSize(new java.awt.Dimension(611, 419));
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        jSplitPane1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jSplitPane1.setDividerLocation(150);

        jPanel4.setMinimumSize(new java.awt.Dimension(150, 300));
        jPanel4.setPreferredSize(new java.awt.Dimension(150, 300));

        filterChooser.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "All", "Leader", "Change", "Ignite" }));
        filterChooser.setToolTipText("Filter List");
        filterChooser.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                filterChooserActionPerformed(evt);
            }
        });

        searchBox.setText("Search");
        searchBox.setToolTipText("Search List");
        searchBox.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                searchBoxFocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                searchBoxFocusLost(evt);
            }
        });
        searchBox.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyReleased(java.awt.event.KeyEvent evt) {
                searchBoxKeyReleased(evt);
            }
        });

        filter.setFont(new java.awt.Font("Verdana", 0, 11));
        filter.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        filter.setLabelFor(filterChooser);
        filter.setText("Showing: " + filterChooser.getSelectedItem() + " (" + ml.getMembers().size() + ")");
        filter.setAlignmentY(0.0F);
        filter.setVerticalTextPosition(javax.swing.SwingConstants.TOP);

        ml.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                mlValueChanged(evt);
            }
        });
        jScrollPane1.setViewportView(ml);

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 128, Short.MAX_VALUE)
                    .addComponent(filterChooser, javax.swing.GroupLayout.Alignment.LEADING, 0, 128, Short.MAX_VALUE)
                    .addComponent(filter, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 128, Short.MAX_VALUE)
                    .addComponent(searchBox, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 128, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(filterChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 367, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(searchBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(filter, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        jSplitPane1.setLeftComponent(jPanel4);

        details.setBorder(javax.swing.BorderFactory.createTitledBorder("Details"));
        details.setMinimumSize(new java.awt.Dimension(200, 0));

        jLabel4.setFont(new java.awt.Font("Verdana", 0, 12));
        jLabel4.setText("ADDRESS");

        jScrollPane2.setFont(new java.awt.Font("Verdana", 0, 12));

        address.setBackground(new java.awt.Color(240, 240, 240));
        address.setColumns(20);
        address.setEditable(false);
        address.setFont(new java.awt.Font("Verdana", 0, 12));
        address.setLineWrap(true);
        address.setRows(4);
        address.setWrapStyleWord(true);
        address.setBorder(null);
        jScrollPane2.setViewportView(address);

        jLabel11.setFont(new java.awt.Font("Verdana", 0, 12));
        jLabel11.setText("OTHER INFORMATION");

        jScrollPane3.setFont(new java.awt.Font("Verdana", 0, 12));

        other.setBackground(new java.awt.Color(240, 240, 240));
        other.setColumns(20);
        other.setEditable(false);
        other.setFont(new java.awt.Font("Verdana", 0, 12));
        other.setLineWrap(true);
        other.setRows(4);
        other.setWrapStyleWord(true);
        other.setBorder(null);
        jScrollPane3.setViewportView(other);

        jLabel5.setFont(new java.awt.Font("Verdana", 0, 12));
        jLabel5.setText("MOTHER");

        medical.setEditable(false);
        medical.setFont(new java.awt.Font("Verdana", 0, 14));
        medical.setBorder(null);

        jLabel3.setFont(new java.awt.Font("Verdana", 0, 12));
        jLabel3.setText("MOBILE");

        nameLabel.setFont(new java.awt.Font("Verdana", 0, 12));
        nameLabel.setText("NAME");

        jLabel2.setFont(new java.awt.Font("Verdana", 0, 12));
        jLabel2.setText("EMAIL");

        mum.setEditable(false);
        mum.setFont(new java.awt.Font("Verdana", 0, 14));
        mum.setBorder(null);

        jLabel6.setFont(new java.awt.Font("Verdana", 0, 12));
        jLabel6.setText("FATHER");

        dad.setEditable(false);
        dad.setFont(new java.awt.Font("Verdana", 0, 14));
        dad.setBorder(null);

        name.setEditable(false);
        name.setFont(new java.awt.Font("Verdana", 0, 14));
        name.setBorder(null);

        sosNum.setEditable(false);
        sosNum.setFont(new java.awt.Font("Verdana", 0, 14));
        sosNum.setBorder(null);

        jLabel9.setFont(new java.awt.Font("Verdana", 0, 12));
        jLabel9.setText("SOS NO.");

        dob.setEditable(false);
        dob.setFont(new java.awt.Font("Verdana", 0, 14));
        dob.setBorder(null);

        email.setEditable(false);
        email.setFont(new java.awt.Font("Verdana", 0, 10));
        email.setHorizontalAlignment(javax.swing.JTextField.LEFT);
        email.setAutoscrolls(false);
        email.setBorder(null);

        type.setEditable(false);
        type.setFont(new java.awt.Font("Verdana", 0, 14));
        type.setBorder(null);

        jLabel7.setFont(new java.awt.Font("Verdana", 0, 12));
        jLabel7.setText("TYPE");

        jLabel1.setFont(new java.awt.Font("Verdana", 0, 12));
        jLabel1.setText("DOB");

        school.setEditable(false);
        school.setFont(new java.awt.Font("Verdana", 0, 14));
        school.setBorder(null);

        jLabel10.setBackground(new java.awt.Color(0, 255, 102));
        jLabel10.setFont(new java.awt.Font("Verdana", 0, 12));
        jLabel10.setText("MEDICAL");

        mobile.setEditable(false);
        mobile.setFont(new java.awt.Font("Verdana", 0, 14));
        mobile.setBorder(null);

        jLabel8.setFont(new java.awt.Font("Verdana", 0, 12));
        jLabel8.setText("SCHOOL");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel7)
                            .addComponent(nameLabel)
                            .addComponent(jLabel1)
                            .addComponent(jLabel2))
                        .addGap(32, 32, 32)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(email, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)
                            .addComponent(dob, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)
                            .addComponent(name, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)
                            .addGroup(jPanel1Layout.createSequentialGroup()
                                .addComponent(type, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(116, 116, 116))))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5)
                            .addComponent(jLabel9)
                            .addComponent(jLabel3)
                            .addComponent(jLabel6)
                            .addComponent(jLabel8))
                        .addGap(17, 17, 17)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(school, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)
                            .addComponent(dad, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)
                            .addComponent(sosNum, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)
                            .addComponent(mum, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)
                            .addComponent(mobile, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)))
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 66, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(medical, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addComponent(nameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE))
                    .addComponent(name, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(4, 4, 4)
                        .addComponent(jLabel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(type))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE))
                    .addComponent(dob, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addComponent(email))
                    .addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(mobile, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(2, 2, 2)
                        .addComponent(jLabel9, javax.swing.GroupLayout.DEFAULT_SIZE, 23, Short.MAX_VALUE))
                    .addComponent(sosNum, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(mum, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(dad, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(school, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(medical, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, new java.awt.Component[] {dad, dob, medical, mobile, mum, name, school, sosNum});

        javax.swing.GroupLayout detailsLayout = new javax.swing.GroupLayout(details);
        details.setLayout(detailsLayout);
        detailsLayout.setHorizontalGroup(
            detailsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(detailsLayout.createSequentialGroup()
                .addGroup(detailsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(detailsLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(detailsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(detailsLayout.createSequentialGroup()
                                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                            .addGroup(detailsLayout.createSequentialGroup()
                                .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 70, Short.MAX_VALUE)
                                .addGap(175, 175, 175)))
                        .addGroup(detailsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, detailsLayout.createSequentialGroup()
                                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 236, Short.MAX_VALUE)
                                .addGap(4, 4, 4))
                            .addGroup(detailsLayout.createSequentialGroup()
                                .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, 146, Short.MAX_VALUE)
                                .addGap(94, 94, 94))))
                    .addGroup(detailsLayout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addComponent(pic, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(6, 6, 6)
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addGap(4, 4, 4))
        );
        detailsLayout.setVerticalGroup(
            detailsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(detailsLayout.createSequentialGroup()
                .addGroup(detailsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                    .addComponent(pic, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(detailsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabel11, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(detailsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jSplitPane1.setRightComponent(details);

        toolbar.setFloatable(false);
        toolbar.setRollover(true);

        openTB.setIcon(new javax.swing.ImageIcon(getClass().getResource("/changedb/images/open.png"))); // NOI18N
        openTB.setToolTipText("Open File (Ctrl + O)");
        openTB.setFocusable(false);
        openTB.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        openTB.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        openTB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                openActionPerformed(evt);
            }
        });
        toolbar.add(openTB);
        openTB.getAccessibleContext().setAccessibleName("Open");

        saveTB.setIcon(new javax.swing.ImageIcon(getClass().getResource("/changedb/images/save.png"))); // NOI18N
        saveTB.setToolTipText("Save File (Ctrl + S)");
        saveTB.setFocusable(false);
        saveTB.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        saveTB.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        saveTB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveActionPerformed(evt);
            }
        });
        toolbar.add(saveTB);

        saveasTB.setIcon(new javax.swing.ImageIcon(getClass().getResource("/changedb/images/saveas.png"))); // NOI18N
        saveasTB.setToolTipText("SaveFile As (Ctrl + Shift + S)");
        saveasTB.setFocusable(false);
        saveasTB.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        saveasTB.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        saveasTB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveAsActionPerformed(evt);
            }
        });
        toolbar.add(saveasTB);

        encryptTB.setIcon(new javax.swing.ImageIcon(getClass().getResource("/changedb/images/encrypt.png"))); // NOI18N
        encryptTB.setToolTipText("Encrypt File (Ctrl + Alt + S)");
        encryptTB.setFocusable(false);
        encryptTB.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        encryptTB.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        encryptTB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                encryptActionPerformed(evt);
            }
        });
        toolbar.add(encryptTB);

        closeTB.setIcon(new javax.swing.ImageIcon(getClass().getResource("/changedb/images/close.png"))); // NOI18N
        closeTB.setToolTipText("Close Current File (Ctrl + W)");
        closeTB.setFocusable(false);
        closeTB.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        closeTB.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        closeTB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                closeActionPerformed(evt);
            }
        });
        toolbar.add(closeTB);
        toolbar.add(jSeparator1);

        addTB.setIcon(new javax.swing.ImageIcon(getClass().getResource("/changedb/images/add.png"))); // NOI18N
        addTB.setToolTipText("Add Member (Ctrl + N)");
        addTB.setFocusable(false);
        addTB.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        addTB.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        addTB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addActionPerformed(evt);
            }
        });
        toolbar.add(addTB);

        editTB.setIcon(new javax.swing.ImageIcon(getClass().getResource("/changedb/images/edit.png"))); // NOI18N
        editTB.setToolTipText("Edit Selected Member (Ctrl + E)");
        editTB.setFocusable(false);
        editTB.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        editTB.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        editTB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editActionPerformed(evt);
            }
        });
        toolbar.add(editTB);

        deleteTB.setIcon(new javax.swing.ImageIcon(getClass().getResource("/changedb/images/delete.png"))); // NOI18N
        deleteTB.setToolTipText("Delete Selected Member (Delete)");
        deleteTB.setFocusable(false);
        deleteTB.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        deleteTB.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        deleteTB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteActionPerformed(evt);
            }
        });
        toolbar.add(deleteTB);
        toolbar.add(jSeparator2);

        mailto.setIcon(new javax.swing.ImageIcon(getClass().getResource("/changedb/images/mailto.png"))); // NOI18N
        mailto.setToolTipText("Mail-To");
        mailto.setFocusable(false);
        mailto.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        mailto.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        mailto.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                mailtoActionPerformed(evt);
            }
        });
        toolbar.add(mailto);
        toolbar.add(jSeparator3);

        attendanceTB.setIcon(new javax.swing.ImageIcon(getClass().getResource("/changedb/images/attendance.png"))); // NOI18N
        attendanceTB.setToolTipText("Take Attendance (Ctrl + A)");
        attendanceTB.setFocusable(false);
        attendanceTB.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        attendanceTB.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        attendanceTB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                takeAttendanceActionPerformed(evt);
            }
        });
        toolbar.add(attendanceTB);

        viewAttTB.setIcon(new javax.swing.ImageIcon(getClass().getResource("/changedb/images/viewattendance.png"))); // NOI18N
        viewAttTB.setToolTipText("View Attendance");
        viewAttTB.setFocusable(false);
        viewAttTB.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        viewAttTB.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        viewAttTB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                viewAttendanceActionPerformed1(evt);
            }
        });
        toolbar.add(viewAttTB);

        status.setText("Welcome to ChangeDB version: 2.0");
        status.setVerticalAlignment(javax.swing.SwingConstants.TOP);
        status.setAlignmentY(0.2F);
        status.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 3, 1, 3));
        status.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);

        jToolBar1.setFloatable(false);
        jToolBar1.setRollover(true);

        helpTB.setIcon(new javax.swing.ImageIcon(getClass().getResource("/changedb/images/help.png"))); // NOI18N
        helpTB.setToolTipText("Help (F1)");
        helpTB.setFocusable(false);
        helpTB.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        helpTB.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        helpTB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                helpActionPerformed(evt);
            }
        });
        jToolBar1.add(helpTB);

        aboutTB.setIcon(new javax.swing.ImageIcon(getClass().getResource("/changedb/images/about.png"))); // NOI18N
        aboutTB.setToolTipText("About (F2)");
        aboutTB.setFocusable(false);
        aboutTB.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        aboutTB.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        aboutTB.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                aboutActionPerformed(evt);
            }
        });
        jToolBar1.add(aboutTB);

        fileMenu.setText("File");

        open.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));
        open.setIcon(new javax.swing.ImageIcon(getClass().getResource("/changedb/images/openS.png"))); // NOI18N
        open.setText("Open");
        open.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                openActionPerformed(evt);
            }
        });
        fileMenu.add(open);

        jMenu1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/changedb/images/saveS.png"))); // NOI18N
        jMenu1.setText("Save...");

        save.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
        save.setIcon(new javax.swing.ImageIcon(getClass().getResource("/changedb/images/saveS.png"))); // NOI18N
        save.setText("Save...");
        save.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveActionPerformed(evt);
            }
        });
        jMenu1.add(save);

        saveAs.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        saveAs.setIcon(new javax.swing.ImageIcon(getClass().getResource("/changedb/images/saveasS.png"))); // NOI18N
        saveAs.setText("Save As");
        saveAs.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveAsActionPerformed(evt);
            }
        });
        jMenu1.add(saveAs);

        encrypt.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        encrypt.setIcon(new javax.swing.ImageIcon(getClass().getResource("/changedb/images/encryptS.png"))); // NOI18N
        encrypt.setText("Encrypt");
        encrypt.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                encryptActionPerformed(evt);
            }
        });
        jMenu1.add(encrypt);

        fileMenu.add(jMenu1);

        close.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_W, java.awt.event.InputEvent.CTRL_MASK));
        close.setIcon(new javax.swing.ImageIcon(getClass().getResource("/changedb/images/closeS.png"))); // NOI18N
        close.setText("Close");
        close.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                closeActionPerformed(evt);
            }
        });
        fileMenu.add(close);

        exit.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q, java.awt.event.InputEvent.CTRL_MASK));
        exit.setText("Exit");
        exit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                exitActionPerformed(evt);
            }
        });
        fileMenu.add(exit);

        menuBar.add(fileMenu);

        editMenu.setText("Edit");

        add.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK));
        add.setIcon(new javax.swing.ImageIcon(getClass().getResource("/changedb/images/addS.png"))); // NOI18N
        add.setText("Add");
        add.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addActionPerformed(evt);
            }
        });
        editMenu.add(add);

        edit.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.CTRL_MASK));
        edit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/changedb/images/editS.png"))); // NOI18N
        edit.setText("Edit");
        edit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editActionPerformed(evt);
            }
        });
        editMenu.add(edit);

        delete.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_DELETE, 0));
        delete.setIcon(new javax.swing.ImageIcon(getClass().getResource("/changedb/images/deleteS.png"))); // NOI18N
        delete.setText("Delete");
        delete.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                deleteActionPerformed(evt);
            }
        });
        editMenu.add(delete);

        menuBar.add(editMenu);

        jMenu2.setText("Attendance");

        takeAttendance.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK));
        takeAttendance.setIcon(new javax.swing.ImageIcon(getClass().getResource("/changedb/images/attendanceS.png"))); // NOI18N
        takeAttendance.setText("Take Attendance");
        takeAttendance.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                takeAttendanceActionPerformed(evt);
            }
        });
        jMenu2.add(takeAttendance);

        viewAttendance.setIcon(new javax.swing.ImageIcon(getClass().getResource("/changedb/images/viewattendanceS.png"))); // NOI18N
        viewAttendance.setText("View Attendance");
        viewAttendance.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                viewAttendanceActionPerformed1(evt);
            }
        });
        jMenu2.add(viewAttendance);

        menuBar.add(jMenu2);

        helpMenu.setText("Help");

        help.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F1, 0));
        help.setIcon(new javax.swing.ImageIcon(getClass().getResource("/changedb/images/helpS.png"))); // NOI18N
        help.setText("Help");
        help.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                helpActionPerformed(evt);
            }
        });
        helpMenu.add(help);

        about.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F2, 0));
        about.setIcon(new javax.swing.ImageIcon(getClass().getResource("/changedb/images/aboutS.png"))); // NOI18N
        about.setText("About");
        about.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                aboutActionPerformed(evt);
            }
        });
        helpMenu.add(about);

        menuBar.add(helpMenu);

        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(status, javax.swing.GroupLayout.DEFAULT_SIZE, 668, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addComponent(toolbar, javax.swing.GroupLayout.DEFAULT_SIZE, 598, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 668, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(jToolBar1, 0, 0, Short.MAX_VALUE)
                    .addComponent(toolbar, javax.swing.GroupLayout.PREFERRED_SIZE, 26, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 464, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(status, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-684)/2, (screenSize.height-579)/2, 684, 579);
    }// </editor-fold>//GEN-END:initComponents

    private void exitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exitActionPerformed
        if (!saved) {
            int answer1 = JOptionPane.showConfirmDialog(null, "Would you like to save the current file before exiting?",
                    "Save before exit?", JOptionPane.YES_NO_CANCEL_OPTION);
            if (answer1 == JOptionPane.YES_OPTION) {
                if (currentFile == null) {
                    saved = Save.saveAs(ml, false);
                } else {
                    saved = Save.save(currentFile, ml, false);
                }
                if (!saved) {
                    JOptionPane.showMessageDialog(null, "Error saving file.",
                            "Save error", JOptionPane.ERROR_MESSAGE);
                } else {
                    JOptionPane.showMessageDialog(null, "Saved file.", "Saved.", JOptionPane.INFORMATION_MESSAGE);
                }
            } else if (answer1 == JOptionPane.NO_OPTION) {
                saved = true;
            }
        }
        if (saved) {
            int answer2 = JOptionPane.showConfirmDialog(null, "Are you sure you want to quit?",
                    "Quit?", JOptionPane.YES_NO_OPTION);
            if (answer2 == JOptionPane.YES_OPTION) {
                System.exit(0);
            }
        }
    }//GEN-LAST:event_exitActionPerformed

    private void filterChooserActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filterChooserActionPerformed
        String selection = filterChooser.getSelectedItem().toString();
        ml.filter(selection);
        filter.setText("Showing: " + filterChooser.getSelectedItem() + " (" +
                        ml.getMembersClone(filterChooser.getSelectedItem().toString()).size() + ")");
    }//GEN-LAST:event_filterChooserActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        if (!saved) {
            int answer1 = JOptionPane.showConfirmDialog(null, "Would you like to save the current file before exiting?",
                    "Save before exit?", JOptionPane.YES_NO_CANCEL_OPTION);
            if (answer1 == JOptionPane.YES_OPTION) {
                if (currentFile == null) {
                    saved = Save.saveAs(ml, false);
                } else {
                    saved = Save.save(currentFile, ml, false);
                }
                if (!saved) {
                    JOptionPane.showMessageDialog(null, "Error saving file.",
                            "Save error", JOptionPane.ERROR_MESSAGE);
                } else {
                    JOptionPane.showMessageDialog(null, "Saved file.", "Saved.", JOptionPane.INFORMATION_MESSAGE);
                }
            } else if (answer1 == JOptionPane.NO_OPTION) {
                saved = true;
            }
        }
        if (saved) {
            int answer2 = JOptionPane.showConfirmDialog(null, "Are you sure you want to quit?",
                    "Quit?", JOptionPane.YES_NO_OPTION);
            if (answer2 == JOptionPane.YES_OPTION) {
                System.exit(0);
            }
        }
    }//GEN-LAST:event_formWindowClosing

    private void searchBoxFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_searchBoxFocusLost
        if (searchBox.getText().equals("")) {
            searchBox.setText("Search");
            filterChooser.setSelectedIndex(0);
        }
    }//GEN-LAST:event_searchBoxFocusLost

    private void openActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openActionPerformed
        if (!saved) {
            int answer1 = JOptionPane.showConfirmDialog(null, "Would you like to save the current file?",
                    "Save current file?", JOptionPane.YES_NO_CANCEL_OPTION);
            if (answer1 == JOptionPane.YES_OPTION) {
                if (currentFile == null) {
                    saved = Save.saveAs(ml, false);
                } else {
                    saved = Save.save(currentFile, ml, false);
                }
                if (!saved) {
                    JOptionPane.showMessageDialog(null, "Error saving file.",
                            "Save error", JOptionPane.ERROR_MESSAGE);
                } else {
                    JOptionPane.showMessageDialog(null, "Saved file.", "Saved.", JOptionPane.INFORMATION_MESSAGE);
                }
            } else if (answer1 == JOptionPane.NO_OPTION) {
                saved = true;
            }
        }
        if (saved) {
            currentFile = Open.open();
            if (currentFile != null) {
                String success = Open.read(currentFile, ml);
                status.setText(success);
                filter.setText("Showing: " + filterChooser.getSelectedItem() + " (" +
                        ml.getMembersClone(filterChooser.getSelectedItem().toString()).size() + ")");
            } else {
                status.setText("No file selected.");
            }
        }
    }//GEN-LAST:event_openActionPerformed

    private void helpActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_helpActionPerformed
        Help help1 = new Help();
    }//GEN-LAST:event_helpActionPerformed

    private void mlValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_mlValueChanged
        Member m = (Member) ml.getSelectedValue();
        if (m != null) {
            ArrayList<String> al = (ArrayList) m.getDetails();
            File f = new File(System.getProperty("user.dir") + "/images/" + al.get(1).toLowerCase().trim()
                    + al.get(2).toLowerCase().trim() + ".jpg");
            ImageIcon picture;
            if (f.exists()) {
                picture = new ImageIcon(System.getProperty("user.dir") + "/images/" + al.get(1).toLowerCase().trim()
                        + al.get(2).toLowerCase().trim() + ".jpg");
            } else {
                picture = new ImageIcon(System.getProperty("user.dir") + "/images/default.jpg");
            }
            pic.setIcon(picture);
            type.setText(al.get(0));
            name.setText(al.get(1) + " " + al.get(2));
            email.setText(al.get(3));
            mobile.setText(al.get(4));
            dob.setText(al.get(5) + "/" + al.get(6) + "/" + al.get(7));
            address.setText(al.get(8) + "\n" + al.get(9) + "\n" + al.get(10) + "\n" + al.get(11));
            mum.setText(al.get(12));
            dad.setText(al.get(13));
            school.setText(al.get(14));
            sosNum.setText(al.get(15));
            medical.setText(al.get(16));
            other.setText(al.get(17));
        }

    }//GEN-LAST:event_mlValueChanged

    private void closeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeActionPerformed
        if (!saved) {
            int answer1 = JOptionPane.showConfirmDialog(null, "Would you like to save the current file?",
                    "Save current file?", JOptionPane.YES_NO_CANCEL_OPTION);
            if (answer1 == JOptionPane.YES_OPTION) {
                if (currentFile == null) {
                    saved = Save.saveAs(ml, false);
                } else {
                    saved = Save.save(currentFile, ml, false);
                }
                if (!saved) {
                    JOptionPane.showMessageDialog(null, "Error saving file.",
                            "Save error", JOptionPane.ERROR_MESSAGE);
                } else {
                    JOptionPane.showMessageDialog(null, "Saved file.", "Saved.", JOptionPane.INFORMATION_MESSAGE);
                }
            } else if (answer1 == JOptionPane.NO_OPTION) {
                saved = true;
            }
        }
        if (saved) {
            int answer = JOptionPane.showConfirmDialog(null, "Are you sure you want to close the current database?",
                    "Close database?", JOptionPane.YES_NO_OPTION);
            if (answer == JOptionPane.YES_OPTION) {
                ml.setList(new ArrayList<Member>());
                currentFile = null;
                saved = true;
            }
        }
    }//GEN-LAST:event_closeActionPerformed

    private void saveActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveActionPerformed
        if (currentFile == null) {
            saved = Save.saveAs(ml, false);

        } else {
            saved = Save.save(currentFile, ml, false);
        }
        if (saved) {
            status.setText("Save to file " + currentFile + " successful!");
        } else {
            status.setText("Error - Save to file " + currentFile + " failed.");
        }
    }//GEN-LAST:event_saveActionPerformed

    private void saveAsActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveAsActionPerformed
        saved = Save.saveAs(ml, false);
        if (saved) {
            status.setText("Save to file successful!");
        } else {
            status.setText("Error - Save to file failed.");
        }
    }//GEN-LAST:event_saveAsActionPerformed

    private void searchBoxKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_searchBoxKeyReleased
        ml.setSelectedIndex(ml.getSelectedIndex());
        String searchTerm = searchBox.getText();
        ml.search(searchTerm, filterChooser.getSelectedItem().toString());
        if(evt.getKeyCode() == java.awt.event.KeyEvent.VK_ENTER) {
            searchBox.transferFocus();
        }
    }//GEN-LAST:event_searchBoxKeyReleased

    private void searchBoxFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_searchBoxFocusGained
        searchBox.setText("");
    }//GEN-LAST:event_searchBoxFocusGained

    private void deleteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_deleteActionPerformed
        Member m = (Member) ml.getSelectedValue();
        if (m != null) {
            int answer = JOptionPane.showConfirmDialog(null, "Are you sure you want to delete member: " + m,
                    "Confirm delete", JOptionPane.YES_NO_OPTION);
            if (answer == JOptionPane.YES_OPTION) {
                ArrayList<Member> al = (ArrayList) ml.getMembers();
                al.remove(m);
                ml.setList(al);
            }
        } else {
            JOptionPane.showMessageDialog(null, "Please select a member from the list "
                    + "before using the delete function.", "Error",
                    JOptionPane.ERROR_MESSAGE);
        }
        saved = false;
    }//GEN-LAST:event_deleteActionPerformed

    private void addActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addActionPerformed
        MemberFrame memberFrame = new MemberFrame(ml);
        saved = false;
    }//GEN-LAST:event_addActionPerformed

    private void editActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editActionPerformed
        Member m = (Member) ml.getSelectedValue();
        if (m != null) {
            MemberFrame memberFrame = new MemberFrame(ml, m);
        } else {
            JOptionPane.showMessageDialog(null, "Please select a member from the list "
                    + "before using the edit function.", "Error",
                    JOptionPane.ERROR_MESSAGE);
        }
        saved = false;
    }//GEN-LAST:event_editActionPerformed
    
    private void aboutActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_aboutActionPerformed
        JOptionPane.showMessageDialog(null, "ChangeDB v2.0\nWritten by Benjamin Goodwin\nCurrent lines: 3,725", "About",
                JOptionPane.INFORMATION_MESSAGE);
    }//GEN-LAST:event_aboutActionPerformed

    private void takeAttendanceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_takeAttendanceActionPerformed
        Attendance attendance1 = new Attendance(ml);
    }//GEN-LAST:event_takeAttendanceActionPerformed

    private void mailtoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mailtoActionPerformed
        MailTo mailTo = new MailTo(ml);
    }//GEN-LAST:event_mailtoActionPerformed

    private void viewAttendanceActionPerformed1(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewAttendanceActionPerformed1
        AttendanceView av = new AttendanceView();
    }//GEN-LAST:event_viewAttendanceActionPerformed1

    private void encryptActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_encryptActionPerformed
        saved = Save.saveAs(ml, true);
        if (saved) {
            status.setText("Save to encrypted file successful!");
        } else {
            status.setText("Error - Save to encrypted file failed.");
        }
    }//GEN-LAST:event_encryptActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new MainFrame().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem about;
    private javax.swing.JButton aboutTB;
    private javax.swing.JMenuItem add;
    private javax.swing.JButton addTB;
    private javax.swing.JTextArea address;
    private javax.swing.JButton attendanceTB;
    private javax.swing.JMenuItem close;
    private javax.swing.JButton closeTB;
    private javax.swing.JTextField dad;
    private javax.swing.JMenuItem delete;
    private javax.swing.JButton deleteTB;
    private javax.swing.JPanel details;
    private javax.swing.JTextField dob;
    private javax.swing.JMenuItem edit;
    private javax.swing.JMenu editMenu;
    private javax.swing.JButton editTB;
    private javax.swing.JTextField email;
    private javax.swing.JMenuItem encrypt;
    private javax.swing.JButton encryptTB;
    private javax.swing.JMenuItem exit;
    private javax.swing.JMenu fileMenu;
    private javax.swing.JLabel filter;
    private javax.swing.JComboBox filterChooser;
    private javax.swing.JMenuItem help;
    private javax.swing.JMenu helpMenu;
    private javax.swing.JButton helpTB;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JToolBar.Separator jSeparator1;
    private javax.swing.JToolBar.Separator jSeparator2;
    private javax.swing.JToolBar.Separator jSeparator3;
    private javax.swing.JSplitPane jSplitPane1;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JButton mailto;
    private javax.swing.JTextField medical;
    private javax.swing.JMenuBar menuBar;
    private changedb.MembersList ml;
    private javax.swing.JTextField mobile;
    private javax.swing.JTextField mum;
    private javax.swing.JTextField name;
    private javax.swing.JLabel nameLabel;
    private javax.swing.JMenuItem open;
    private javax.swing.JButton openTB;
    private javax.swing.JTextArea other;
    private javax.swing.JLabel pic;
    private javax.swing.JMenuItem save;
    private javax.swing.JMenuItem saveAs;
    private javax.swing.JButton saveTB;
    private javax.swing.JButton saveasTB;
    private javax.swing.JTextField school;
    private javax.swing.JTextField searchBox;
    private javax.swing.JTextField sosNum;
    private javax.swing.JLabel status;
    private javax.swing.JMenuItem takeAttendance;
    private javax.swing.JToolBar toolbar;
    private javax.swing.JTextField type;
    private javax.swing.JButton viewAttTB;
    private javax.swing.JMenuItem viewAttendance;
    // End of variables declaration//GEN-END:variables
    private File currentFile;
    private boolean saved = true;

    private void createImages() {
        File file = new File(System.getProperty("user.dir") + "/images/");
        if (!(file.exists())) {
            file.mkdir();
        }
        File f = new File(System.getProperty("user.dir") + "/images/" + "default.jpg");
        if (!f.exists()) {
            try {
                BufferedImage i = ImageIO.read(this.getClass().getResource("default.jpg"));
                ImageIO.write(i, "jpg", new File(System.getProperty("user.dir") + "/images/"
                        + "default.jpg"));
            } catch (Exception e) {
            }
        }
    }
}
